import logging as log
import pathlib
from typing import Tuple
import toml

def get_api_key(key:str="GOOGLE_API_KEY"):
    try:
        import os
        api_key = os.environ[key]
    except ImportError:
        log.error(f"从环境变量中获取{key}失败")
    log.info(f"API_KEY：{api_key}")
    return api_key
    
def get_toml_config_file(filepath:str="config.toml"):
    path = pathlib.Path().cwd().joinpath(filepath)
    log.debug(f"配置文件路径：{path}")

    with open(path,mode='r',encoding="utf-8") as fp:
        config = toml.load(fp)
    log.debug(f"加载配置文件：{filepath}完成")
    return config